var $D=YAHOO.util.Dom;
var $E=YAHOO.util.Event;
var select=YAHOO.util.Selector.query; 
var get=$D.get;

var counterObject = function(container, nw, en) {
  this.container = container;
  this.countTime = en-nw;
  if(this.countTime > 0) {
    YAHOO.lang.later(1000, this, this.process, null, true);
  }
}

counterObject.prototype = {
  process: function() {
    var theDate = new Date(this.countBack() * 1000);
    var dateString = theDate.toGMTString();
    var arrDateStr = dateString.split(" ");
    
    var days = arrDateStr[1]-1;
    if(days<10) {
      days='0'+days;
    }
    var hours = arrDateStr[4].substr(0,2);
    var mins  = arrDateStr[4].substr(3,2);
    var secs = arrDateStr[4].substr(6,2);

    this.update(days, 'd');
    this.update(hours, 'h');
    this.update(mins, 'm');
    this.update(secs, 's');
  },
  update: function(v, w)
  {
    var selected = select('.'+w, this.container, true);
    if(selected) {
      selected.innerHTML = v;
    }
  },
  countBack: function()
  {
    this.countTime = this.countTime-1;
    if(this.countTime > 0) {
      return this.countTime;
    }
    else {
      return 0;
    }
  }
}
